//
//  VC_RegistSetPassword.m
//  yjw-winner
//
//  Created by 隆霁 on 2018/9/20.
//  Copyright © 2018年 Shanghai decade financial information service co., LTD. All rights reserved.
//

#import "VC_RegistSetPassword.h"
#import "VC_RegistSucceed.h"

@interface VC_RegistSetPassword ()
@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UILabel *phoneNumberLabel;
@property (weak, nonatomic) IBOutlet UIButton *submitButton;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
@property (weak, nonatomic) IBOutlet UITextField *makesurePasswordTextField;

@end

@implementation VC_RegistSetPassword

- (void)viewDidLoad {
    [super viewDidLoad];

    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.layer.cornerRadius = self.headImageView.mj_w * 0.5;
    
    self.submitButton.layer.masksToBounds = YES;
    self.submitButton.layer.cornerRadius = 4.0f;
    
    NSString *lt = [NSString stringWithFormat:@"您注册的手机号为%@", self.phoneNumber];
    NSMutableAttributedString *mt = [[NSMutableAttributedString alloc] initWithString:lt];
    [mt addAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} range:[lt rangeOfString:self.phoneNumber]];
    self.phoneNumberLabel.attributedText = mt;
}

#pragma mark --mark EVENT

- (IBAction)submitButtonClick:(UIButton *)sender {
    NSString *password = self.passwordTextField.text;
    NSString *makesurePassword = self.makesurePasswordTextField.text;
    if (password.length >= 8 && password.length <= 16 && [makesurePassword isEqualToString:password]) {
        // 注册
        VC_RegistSucceed *vc = [[UIStoryboard storyboardWithName:@"LoginStoryBoard" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([VC_RegistSucceed class])];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (password.length < 8 || password.length > 16) {
        [MBProgressHUD showSuccess:@"密码格式错误"];
    }
    if (![password isEqualToString:makesurePassword]) {
        [MBProgressHUD showSuccess:@"两次密码不一致"];
    }
}


@end
